package BC106_上三角矩阵判定;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] num = new int[n][n];


        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                num[i][j] = sc.nextInt();
            }
        }

        for (int i = 0; i < n; i++){
            for (int j = 0; j < i; j++){
                if (num[i][j] != 0){
                    System.out.println("NO");
                    return;
                }
            }
        }
        System.out.println("YES");
    }
}